package com.kunbo.cn.controller.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kunbo.cn.entity.system.Depart;
import com.kunbo.cn.service.system.DepartService;
import com.kunbo.cn.util.retu.CommonResult;

@RestController
@RequestMapping("/depart")
public class DepartController {
	
	@Autowired
	private DepartService departService;
	
	@RequestMapping("/getTreeList")
	public List getTreeList() {
		List list = departService.getDepartTreeList();
		return list;
	}
	
	//部门新增
	@RequestMapping("/add")
	public CommonResult addDepart(Depart depart) {
		departService.save(depart);
		return new CommonResult(true,"操作成功",null);
	}
	
	@RequestMapping("/update")
	public CommonResult updateDepart(Depart depart) {
		departService.update(depart);
		return new CommonResult(true,"操作成功",null);
	}
	
	@RequestMapping("/findById")
	public Depart findById(String id) {
		Depart d = departService.findById(id);
		return d;
	}
	//条件分页查询部门
	@RequestMapping("/findDepartByName")
	public Page<Depart> findDepartByName(String name,Integer pageNo,Integer pageSize) {
		Page<Depart> page = departService.findDepartByName(name, pageNo, pageSize);
		return page;
	}

}
